# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tcpcopy
pkgver=1285.929511d
pkgrel=1
pkgdesc='A TCP stream replay tool to support real testing of Internet server applications.'
groups=('blackarch' 'blackarch-networking')
arch=('x86_64' 'aarch64')
url='https://github.com/session-replay-tools/tcpcopy'
license=('BSD')
depends=('libpcap')
makedepends=('git')
source=("git+https://github.com/session-replay-tools/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  ./configure --prefix=/usr/share/tcpcopy --sbin-path=/usr/share/tcpcopy/tcpcopy

  make
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  make DESTDIR="$pkgdir" install

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md AUTHORS NEWS \
    ChangeLog README
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE COPYING

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

